#! /usr/bin/python

# Bird_upAbout.py

import wx

ID_DEPTH = 1

class BirdUpAbout(wx.Dialog):
    """About dialog for bird_up.py, a gui bird uploading program"""
    def __init__(self, parent, id, title='About'):
        wx.Dialog.__init__(self, parent, id, title, size=(450, 680))
        
        # Set the fonts
        self.dfont = wx.SystemSettings_GetFont(wx.SYS_SYSTEM_FONT)
        self.dfont.SetPointSize(11)
        self.dtitleFont = wx.SystemSettings_GetFont(wx.SYS_SYSTEM_FONT)
        self.dtitleFont.SetPointSize(18)
        self.dlicenceFont = wx.SystemSettings_GetFont(wx.SYS_SYSTEM_FONT)
        self.dlicenceFont.SetPointSize(9)
        
        # Start working on the gui framework
        self.dpanel = wx.Panel(self, -1)
        dvbox = wx.BoxSizer(wx.VERTICAL)
        
        # Breathing room
        dvbox.Add((-1, 15))
        
        # Logo
        dhboxL = wx.BoxSizer(wx.HORIZONTAL)
        logo = wx.Image('things/sandcurves.png', wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        self.birder = wx.StaticBitmap(self.dpanel, -1, logo, (10, 5))
        dhboxL.Add(self.birder, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL | wx.TOP, 8)
        dvbox.Add(dhboxL, 0, wx.ALIGN_CENTER)
        
        # Breathing room
        dvbox.Add((-1, 15))
        
        # First level - Title
        dhbox1 = wx.BoxSizer(wx.HORIZONTAL)        
        self.dtitle = "Blupy Bird List Uploader 0.1a"
        self.dtitle_txt = wx.StaticText(self.dpanel, -1, self.dtitle)
        self.dtitle_txt.SetFont(self.dtitleFont)
        dhbox1.Add(self.dtitle_txt, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.TOP, 8)
        dvbox.Add(dhbox1, 0, wx.ALIGN_CENTER)
        
        # Breathing room
        dvbox.Add((-1, 25))
        
        # Description
        dhbox2 = wx.BoxSizer(wx.HORIZONTAL)
        description = """An application for uploading bird lists to a mysql database.
It is written in the Python"""
        self.descript = wx.StaticText(self.dpanel, -1, description,  style=wx.EXPAND)
        self.descript.SetFont(self.dlicenceFont)
        dhbox2.Add(self.descript, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL | wx.TOP, 8)
        dvbox.Add(dhbox2, 0, wx.ALIGN_CENTER)
        
        # Breath!
        dvbox.Add((-1, 25))
        
        # Copyright Note
        dhbox3 = wx.BoxSizer(wx.HORIZONTAL)        
        copyright = "Copyright%s %s Vernon Swanepoel" % (u'\xa9', self.copyrightText())
        self.dcpr = wx.StaticText(self.dpanel, -1, copyright)
        self.dcpr.SetFont(self.dfont)
        dhbox3.Add(self.dcpr, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL | wx.TOP, 8)
        dvbox.Add(dhbox3, 0, wx.ALIGN_CENTER)
        
        # Ah! breath again
        dvbox.Add((-1, 25))        
        
        # Licence
        dhbox4 = wx.BoxSizer(wx.HORIZONTAL)
        licence = """Bird List Uploader is licenced
under the GNU General Public Licence (GPL)

This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""
        self.dlic = wx.StaticText(self.dpanel, -1, licence)
        self.dlic.SetFont(self.dlicenceFont)
        dhbox4.Add(self.dlic, 0, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL | wx.TOP, 8)
        dvbox.Add(dhbox4, 0, wx.ALIGN_CENTER)
        
        # Breath!
        dvbox.Add((-1, 25))
        
        #Buttons
        dhbox_buttons = wx.BoxSizer(wx.HORIZONTAL)       
        dexit_button = wx.Button(self.dpanel, -1, "Close", size=(70, 30))
        dhbox_buttons.Add(dexit_button, 0)
        dvbox.Add(dhbox_buttons, 0, wx.ALIGN_RIGHT | wx.RIGHT, 10)        
        self.Bind(wx.EVT_BUTTON, self.dOnQuit, id=dexit_button.GetId())        
        
        # Place my panel
        self.dpanel.SetSizer(dvbox)        
        
        # End of the structure part of the module
        
    def copyrightText(self):
        from time import localtime
        if localtime()[0] == 2009:
            crD = "2009"
        else:
            crD = "2009 - %d" % localtime()[0]
        return crD
        
    def dOnQuit(self, event):
        """Close dialog"""
        self.Close()
# End module